# wondger@gmail.com
# Prototype
snippet win
	window
snippet doc
	document
snippet proto
	${1:class_name}.prototype.${2:method_name} =
	function(${3:first_argument}) {
		${4:// body...}
	};
# Function
snippet fn
	function ${1:function_name}(${2:argument}) {
		${3:// body...}
	}
# Anonymous Function
snippet f
	function (${1}) {
		${2}
	};
# if
snippet if
	if (${1:true}) {
		${2}
	}
# if ... else
snippet ife
	if (${1:true}) {
		${2}
	}
	else {
		${3}
	}
# tertiary conditional
snippet t
	${1:/* condition */} ? ${2:a} : ${3:b}
# switch
snippet switch
	switch (${1:expression}) {
		case '${3:case}':
			${4:// code}
			break;
		${5}
		default:
			${2:// code}
	}
# case
snippet case
	case '${1:case}':
		${2:// code}
		break;
	${3}
# for (...) {...}
snippet for
	for (var ${1:i}=0; $1<${2:Things}.length; $1${3:++}) {
		${4:$2[$1]}
	};
# for (...) {...} (Improved Native For-Loop)
snippet forr
	for (var ${1:i}=${2:Things}.length-1; $1>=0; $1${3:--}) {
		${4:$2[$1]}
	};
# while (...) {...}
snippet wh #while
	while (${1:/* condition */}) {
		${2:/* code */}
	}
# do...while
snippet do
	do {
		${2:/* code */}
	} while(${1:/* condition */});
# Object Method
snippet :f
	${1:method_name}: function (${2:attribute}) {
		${4}
	}${3:,}
# setTimeout function
snippet timeout
	setTimeout(${1}, ${2:10});${3}
# setInterval function
snippet interval
	setInterval(${1}, ${2:10});${3}
# Get Elements
snippet gett
	getElementsByTagName('${1}')${2}
# Get Element
snippet geti
	getElementById('${1}')${2}
snippet try
	try {
		${1}
	}
	catch (e) {
		${2}
	}

# console
snippet debug
	try {
		console.debug(${1});
	}
	catch (e) {
		${2}
	}
snippet dir
	try {
		console.dir(${1});
	}
	catch (e) {
		${2}
	}

# KISSY
snippet S.add
	S.add("${1:}", function(S) {
		var $1 = function (${2:cfg}) {
			if (!(this instanceof $1)) {
				return new $1($2);
			}

			$2 = $2 || {};

			${3}

			this._init();
		};

		S.augment($1, {
			_init: function() {
			}
		});

		return $1;
	});
snippet KISSY.add
	KISSY.add("${1:}", function(S) {
		var $1 = function (${2:cfg}) {
			if (!(this instanceof $1)) {
				return new $1($2);
			}

			$2 = $2 || {};

			${3}

			this._init();
		};

		S.augment($1, {
			_init: function() {
			}
		});

		return $1;
	});
snippet S.use
	S.use("${1:}", function(S, $1) {
		${2}
	});
snippet KISSY.use
	KISSY.use("${1:}", function(S, $1) {
		${2}
	});
snippet S.ready
	S.ready(function(S) {
		${1}
	});
snippet KISSY.ready
	KISSY.ready(function(S) {
		${1}
	});
# Node
snippet log
	console.log(${1});${2}
snippet rq
	require('${1}');${2}
snippet cs
	createServer(${1}).listen(${2:8888});${3}
snippet wh #writeHeader
	writeHeader(${1:200},{${2:'Content-Type':'text/plain'}});${3}
	
